using System.Net;
using System.Net.WebSockets;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();

var app = builder.Build();

// Configure the HTTP request pipeline.
var webSocketOptions = new WebSocketOptions()
{
    KeepAliveInterval = TimeSpan.FromSeconds(10),
};

app.UseWebSockets(webSocketOptions);



//app.Use(async (context, next) =>
//{

//    if (context.WebSockets.IsWebSocketRequest)
//    {
//        using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync())
//        {
//            var socketFinishedTcs = new TaskCompletionSource<object>();

//            BackgroundSocketProcessor.AddSocket(webSocket, socketFinishedTcs);

//            await socketFinishedTcs.Task;
//        }
//    }
//    else
//    {
//        await next();
//    }

//});

app.UseAuthorization();
app.MapControllers();

app.Run();
